package org.nterlearning.datamodel.catalog.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import org.nterlearning.datamodel.catalog.model.CourseRecord;
import org.nterlearning.datamodel.catalog.model.CourseRecordModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the CourseRecord service. Represents a row in the &quot;CATALOG_CourseRecord&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link org.nterlearning.datamodel.catalog.model.CourseRecordModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CourseRecordImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see CourseRecordImpl
 * @see org.nterlearning.datamodel.catalog.model.CourseRecord
 * @see org.nterlearning.datamodel.catalog.model.CourseRecordModel
 * @generated
 */
public class CourseRecordModelImpl extends BaseModelImpl<CourseRecord>
    implements CourseRecordModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a course record model instance should use the {@link org.nterlearning.datamodel.catalog.model.CourseRecord} interface instead.
     */
    public static final String TABLE_NAME = "CATALOG_CourseRecord";
    public static final Object[][] TABLE_COLUMNS = {
            { "courseRecordId", Types.BIGINT },
            { "feedReferenceId", Types.BIGINT },
            { "courseRecordIri", Types.VARCHAR },
            { "userId", Types.BIGINT },
            { "singleSignOnValue", Types.VARCHAR },
            { "courseIri", Types.VARCHAR },
            { "updatedDate", Types.TIMESTAMP },
            { "completionStatus", Types.VARCHAR },
            { "removed", Types.BOOLEAN },
            { "removedDate", Types.TIMESTAMP },
            { "userHidden", Types.BOOLEAN },
            { "assigned", Types.BOOLEAN }
        };
    public static final String TABLE_SQL_CREATE = "create table CATALOG_CourseRecord (courseRecordId LONG not null primary key,feedReferenceId LONG,courseRecordIri VARCHAR(255) null,userId LONG,singleSignOnValue VARCHAR(255) null,courseIri VARCHAR(255) null,updatedDate DATE null,completionStatus VARCHAR(50) null,removed BOOLEAN,removedDate DATE null,userHidden BOOLEAN,assigned BOOLEAN)";
    public static final String TABLE_SQL_DROP = "drop table CATALOG_CourseRecord";
    public static final String ORDER_BY_JPQL = " ORDER BY courseRecord.updatedDate ASC";
    public static final String ORDER_BY_SQL = " ORDER BY CATALOG_CourseRecord.updatedDate ASC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.org.nterlearning.datamodel.catalog.model.CourseRecord"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.org.nterlearning.datamodel.catalog.model.CourseRecord"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.org.nterlearning.datamodel.catalog.model.CourseRecord"),
            true);
    public static long COURSEIRI_COLUMN_BITMASK = 1L;
    public static long COURSERECORDIRI_COLUMN_BITMASK = 2L;
    public static long FEEDREFERENCEID_COLUMN_BITMASK = 4L;
    public static long SINGLESIGNONVALUE_COLUMN_BITMASK = 8L;
    public static long USERID_COLUMN_BITMASK = 16L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.org.nterlearning.datamodel.catalog.model.CourseRecord"));
    private static ClassLoader _classLoader = CourseRecord.class.getClassLoader();
    private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
            CourseRecord.class
        };
    private long _courseRecordId;
    private long _feedReferenceId;
    private long _originalFeedReferenceId;
    private boolean _setOriginalFeedReferenceId;
    private String _courseRecordIri;
    private String _originalCourseRecordIri;
    private long _userId;
    private String _userUuid;
    private long _originalUserId;
    private boolean _setOriginalUserId;
    private String _singleSignOnValue;
    private String _originalSingleSignOnValue;
    private String _courseIri;
    private String _originalCourseIri;
    private Date _updatedDate;
    private String _completionStatus;
    private boolean _removed;
    private Date _removedDate;
    private boolean _userHidden;
    private boolean _assigned;
    private transient ExpandoBridge _expandoBridge;
    private long _columnBitmask;
    private CourseRecord _escapedModelProxy;

    public CourseRecordModelImpl() {
    }

    public long getPrimaryKey() {
        return _courseRecordId;
    }

    public void setPrimaryKey(long primaryKey) {
        setCourseRecordId(primaryKey);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_courseRecordId);
    }

    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    public Class<?> getModelClass() {
        return CourseRecord.class;
    }

    public String getModelClassName() {
        return CourseRecord.class.getName();
    }

    public long getCourseRecordId() {
        return _courseRecordId;
    }

    public void setCourseRecordId(long courseRecordId) {
        _courseRecordId = courseRecordId;
    }

    public long getFeedReferenceId() {
        return _feedReferenceId;
    }

    public void setFeedReferenceId(long feedReferenceId) {
        _columnBitmask |= FEEDREFERENCEID_COLUMN_BITMASK;

        if (!_setOriginalFeedReferenceId) {
            _setOriginalFeedReferenceId = true;

            _originalFeedReferenceId = _feedReferenceId;
        }

        _feedReferenceId = feedReferenceId;
    }

    public long getOriginalFeedReferenceId() {
        return _originalFeedReferenceId;
    }

    public String getCourseRecordIri() {
        if (_courseRecordIri == null) {
            return StringPool.BLANK;
        } else {
            return _courseRecordIri;
        }
    }

    public void setCourseRecordIri(String courseRecordIri) {
        _columnBitmask |= COURSERECORDIRI_COLUMN_BITMASK;

        if (_originalCourseRecordIri == null) {
            _originalCourseRecordIri = _courseRecordIri;
        }

        _courseRecordIri = courseRecordIri;
    }

    public String getOriginalCourseRecordIri() {
        return GetterUtil.getString(_originalCourseRecordIri);
    }

    public long getUserId() {
        return _userId;
    }

    public void setUserId(long userId) {
        _columnBitmask |= USERID_COLUMN_BITMASK;

        if (!_setOriginalUserId) {
            _setOriginalUserId = true;

            _originalUserId = _userId;
        }

        _userId = userId;
    }

    public String getUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
    }

    public void setUserUuid(String userUuid) {
        _userUuid = userUuid;
    }

    public long getOriginalUserId() {
        return _originalUserId;
    }

    public String getSingleSignOnValue() {
        if (_singleSignOnValue == null) {
            return StringPool.BLANK;
        } else {
            return _singleSignOnValue;
        }
    }

    public void setSingleSignOnValue(String singleSignOnValue) {
        _columnBitmask |= SINGLESIGNONVALUE_COLUMN_BITMASK;

        if (_originalSingleSignOnValue == null) {
            _originalSingleSignOnValue = _singleSignOnValue;
        }

        _singleSignOnValue = singleSignOnValue;
    }

    public String getOriginalSingleSignOnValue() {
        return GetterUtil.getString(_originalSingleSignOnValue);
    }

    public String getCourseIri() {
        if (_courseIri == null) {
            return StringPool.BLANK;
        } else {
            return _courseIri;
        }
    }

    public void setCourseIri(String courseIri) {
        _columnBitmask |= COURSEIRI_COLUMN_BITMASK;

        if (_originalCourseIri == null) {
            _originalCourseIri = _courseIri;
        }

        _courseIri = courseIri;
    }

    public String getOriginalCourseIri() {
        return GetterUtil.getString(_originalCourseIri);
    }

    public Date getUpdatedDate() {
        return _updatedDate;
    }

    public void setUpdatedDate(Date updatedDate) {
        _columnBitmask = -1L;

        _updatedDate = updatedDate;
    }

    public String getCompletionStatus() {
        if (_completionStatus == null) {
            return StringPool.BLANK;
        } else {
            return _completionStatus;
        }
    }

    public void setCompletionStatus(String completionStatus) {
        _completionStatus = completionStatus;
    }

    public boolean getRemoved() {
        return _removed;
    }

    public boolean isRemoved() {
        return _removed;
    }

    public void setRemoved(boolean removed) {
        _removed = removed;
    }

    public Date getRemovedDate() {
        return _removedDate;
    }

    public void setRemovedDate(Date removedDate) {
        _removedDate = removedDate;
    }

    public boolean getUserHidden() {
        return _userHidden;
    }

    public boolean isUserHidden() {
        return _userHidden;
    }

    public void setUserHidden(boolean userHidden) {
        _userHidden = userHidden;
    }

    public boolean getAssigned() {
        return _assigned;
    }

    public boolean isAssigned() {
        return _assigned;
    }

    public void setAssigned(boolean assigned) {
        _assigned = assigned;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public CourseRecord toEscapedModel() {
        if (_escapedModelProxy == null) {
            _escapedModelProxy = (CourseRecord) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelProxyInterfaces,
                    new AutoEscapeBeanHandler(this));
        }

        return _escapedModelProxy;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        if (_expandoBridge == null) {
            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
                    CourseRecord.class.getName(), getPrimaryKey());
        }

        return _expandoBridge;
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        getExpandoBridge().setAttributes(serviceContext);
    }

    @Override
    public Object clone() {
        CourseRecordImpl courseRecordImpl = new CourseRecordImpl();

        courseRecordImpl.setCourseRecordId(getCourseRecordId());
        courseRecordImpl.setFeedReferenceId(getFeedReferenceId());
        courseRecordImpl.setCourseRecordIri(getCourseRecordIri());
        courseRecordImpl.setUserId(getUserId());
        courseRecordImpl.setSingleSignOnValue(getSingleSignOnValue());
        courseRecordImpl.setCourseIri(getCourseIri());
        courseRecordImpl.setUpdatedDate(getUpdatedDate());
        courseRecordImpl.setCompletionStatus(getCompletionStatus());
        courseRecordImpl.setRemoved(getRemoved());
        courseRecordImpl.setRemovedDate(getRemovedDate());
        courseRecordImpl.setUserHidden(getUserHidden());
        courseRecordImpl.setAssigned(getAssigned());

        courseRecordImpl.resetOriginalValues();

        return courseRecordImpl;
    }

    public int compareTo(CourseRecord courseRecord) {
        int value = 0;

        value = DateUtil.compareTo(getUpdatedDate(),
                courseRecord.getUpdatedDate());

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        CourseRecord courseRecord = null;

        try {
            courseRecord = (CourseRecord) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long primaryKey = courseRecord.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        CourseRecordModelImpl courseRecordModelImpl = this;

        courseRecordModelImpl._originalFeedReferenceId = courseRecordModelImpl._feedReferenceId;

        courseRecordModelImpl._setOriginalFeedReferenceId = false;

        courseRecordModelImpl._originalCourseRecordIri = courseRecordModelImpl._courseRecordIri;

        courseRecordModelImpl._originalUserId = courseRecordModelImpl._userId;

        courseRecordModelImpl._setOriginalUserId = false;

        courseRecordModelImpl._originalSingleSignOnValue = courseRecordModelImpl._singleSignOnValue;

        courseRecordModelImpl._originalCourseIri = courseRecordModelImpl._courseIri;

        courseRecordModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<CourseRecord> toCacheModel() {
        CourseRecordCacheModel courseRecordCacheModel = new CourseRecordCacheModel();

        courseRecordCacheModel.courseRecordId = getCourseRecordId();

        courseRecordCacheModel.feedReferenceId = getFeedReferenceId();

        courseRecordCacheModel.courseRecordIri = getCourseRecordIri();

        String courseRecordIri = courseRecordCacheModel.courseRecordIri;

        if ((courseRecordIri != null) && (courseRecordIri.length() == 0)) {
            courseRecordCacheModel.courseRecordIri = null;
        }

        courseRecordCacheModel.userId = getUserId();

        courseRecordCacheModel.singleSignOnValue = getSingleSignOnValue();

        String singleSignOnValue = courseRecordCacheModel.singleSignOnValue;

        if ((singleSignOnValue != null) && (singleSignOnValue.length() == 0)) {
            courseRecordCacheModel.singleSignOnValue = null;
        }

        courseRecordCacheModel.courseIri = getCourseIri();

        String courseIri = courseRecordCacheModel.courseIri;

        if ((courseIri != null) && (courseIri.length() == 0)) {
            courseRecordCacheModel.courseIri = null;
        }

        Date updatedDate = getUpdatedDate();

        if (updatedDate != null) {
            courseRecordCacheModel.updatedDate = updatedDate.getTime();
        } else {
            courseRecordCacheModel.updatedDate = Long.MIN_VALUE;
        }

        courseRecordCacheModel.completionStatus = getCompletionStatus();

        String completionStatus = courseRecordCacheModel.completionStatus;

        if ((completionStatus != null) && (completionStatus.length() == 0)) {
            courseRecordCacheModel.completionStatus = null;
        }

        courseRecordCacheModel.removed = getRemoved();

        Date removedDate = getRemovedDate();

        if (removedDate != null) {
            courseRecordCacheModel.removedDate = removedDate.getTime();
        } else {
            courseRecordCacheModel.removedDate = Long.MIN_VALUE;
        }

        courseRecordCacheModel.userHidden = getUserHidden();

        courseRecordCacheModel.assigned = getAssigned();

        return courseRecordCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(25);

        sb.append("{courseRecordId=");
        sb.append(getCourseRecordId());
        sb.append(", feedReferenceId=");
        sb.append(getFeedReferenceId());
        sb.append(", courseRecordIri=");
        sb.append(getCourseRecordIri());
        sb.append(", userId=");
        sb.append(getUserId());
        sb.append(", singleSignOnValue=");
        sb.append(getSingleSignOnValue());
        sb.append(", courseIri=");
        sb.append(getCourseIri());
        sb.append(", updatedDate=");
        sb.append(getUpdatedDate());
        sb.append(", completionStatus=");
        sb.append(getCompletionStatus());
        sb.append(", removed=");
        sb.append(getRemoved());
        sb.append(", removedDate=");
        sb.append(getRemovedDate());
        sb.append(", userHidden=");
        sb.append(getUserHidden());
        sb.append(", assigned=");
        sb.append(getAssigned());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBundler sb = new StringBundler(40);

        sb.append("<model><model-name>");
        sb.append("org.nterlearning.datamodel.catalog.model.CourseRecord");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>courseRecordId</column-name><column-value><![CDATA[");
        sb.append(getCourseRecordId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>feedReferenceId</column-name><column-value><![CDATA[");
        sb.append(getFeedReferenceId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>courseRecordIri</column-name><column-value><![CDATA[");
        sb.append(getCourseRecordIri());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userId</column-name><column-value><![CDATA[");
        sb.append(getUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>singleSignOnValue</column-name><column-value><![CDATA[");
        sb.append(getSingleSignOnValue());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>courseIri</column-name><column-value><![CDATA[");
        sb.append(getCourseIri());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>updatedDate</column-name><column-value><![CDATA[");
        sb.append(getUpdatedDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>completionStatus</column-name><column-value><![CDATA[");
        sb.append(getCompletionStatus());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>removed</column-name><column-value><![CDATA[");
        sb.append(getRemoved());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>removedDate</column-name><column-value><![CDATA[");
        sb.append(getRemovedDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userHidden</column-name><column-value><![CDATA[");
        sb.append(getUserHidden());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>assigned</column-name><column-value><![CDATA[");
        sb.append(getAssigned());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
